#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

void test_scoreFor();
/*Tests scores by only testing two sources(deck,hand,discard) at a time
and having one filled with curses and the other filled with estates and the differnce in their size being 1. Results should either be 1 or -1*/
void test_scoreFor(){
	struct gameState *state = newGame();
	int i;
	//Deck Size greater than discard size	
	state->discardCount[0] = 3;
	state->deckCount[0] = 4;
	state->handCount[0] = 0;
	state->numPlayers = 2;
	state->whoseTurn = 0;
	for(i=0;i<state->deckCount[0] ;i++){
		state->deck[0][i] = 1;
	}
	for(i=0;i<state->discardCount[0];i++){
		state->discard[0][i] = 0;
	}
	
	if(scoreFor(0,state) == 1){
		printf("scoreFor(): PASS for deck size greater then discard\n");
	}	
	else{
		printf("scoreFor(): FAIL for deck size greater than discard\n");
	}
	//Deck size less than discard size
	state->discardCount[0] = 4;
	state->deckCount[0] = 3;
	state->handCount[0] = 0;
	for(i=0;i<state->deckCount[0] ;i++){
		state->deck[0][i] = 1;
	}
	for(i=0;i<state->discardCount[0];i++){
		state->discard[0][i] = 0;
	}
	//printf("deck %d %d %d\n",state->deck[0][0],state->deck[0][1],state->deck[0][2]);
	//printf("discard %d %d %d %d\n", state->discard[0][0], state->discard[0][1], state->discard[0][2], state->discard[0][3]);
	if(scoreFor(0,state) == -1){
		printf("scoreFor(): PASS for deck size less than discard\n");
	}
	else{
		printf("scoreFor(): FAIL for deck size less than discard\n");
	}
	//Deck size greater than hand size
	state->discardCount[0] = 0;
	state->deckCount[0] = 4;
	state->handCount[0] = 3;
	for(i=0;i<state->deckCount[0] ;i++){
		state->deck[0][i] = 1;
	}
	for(i=0;i<state->handCount[0];i++){
		state->hand[0][i] = 0;
	}

	if(scoreFor(0,state) == 1){
		printf("scoreFor(): PASS for deck size greater than hand\n");
	}
	else{
		printf("scoreFor(): FAIL for deck size greater than hand\n");
	}
	//Deck Size less than hand size	
	state->discardCount[0] = 0;
	state->deckCount[0] = 3;
	state->handCount[0] = 4;
	state->numPlayers = 2;
	for(i=0;i<state->deckCount[0] ;i++){
		state->deck[0][i] = 1;
	}
	for(i=0;i<state->handCount[0];i++){
		state->hand[0][i] = 0;
	}
	
	if(scoreFor(0,state) == 1){
		printf("scoreFor(): PASS for deck size less than hand\n");
	}
	else{
		printf("scoreFor(): FAIL for deck size less than hand\n");
	}
	//Discard size greater than hand size
	state->discardCount[0] = 4;
	state->deckCount[0] = 0;
	state->handCount[0] = 3;
	for(i=0;i<state->discardCount[0] ;i++){
		state->discard[0][i] = 1;
	}
	for(i=0;i<state->handCount[0];i++){
		state->hand[0][i] = 0;
	}

	if(scoreFor(0,state) == 1){
		printf("scoreFor(): PASS for deck size less than discard\n");
	}
	else{
		printf("scoreFor(): FAIL for deck size less than discard\n");
	}
	//Discard size less than hand size
	state->discardCount[0] = 3;
	state->deckCount[0] = 0;
	state->handCount[0] = 4;
	for(i=0;i<state->discardCount[0] ;i++){
		state->discard[0][i] = 1;
	}
	for(i=0;i<state->handCount[0];i++){
		state->hand[0][i] = 0;
	}

	if(scoreFor(0,state) == -1){
		printf("scoreFor(): PASS for deck size greater than discard\n");
	}
	else{
		printf("scoreFor(): FAIL for deck size greater than discard\n");
	}
}

int main(int argc, char *argv[])
{
        test_scoreFor();
        return 0;
}

